package main

import (
	"fmt"
)

func twoSum(nums []int, target int) {
	vkMap := make(map[int]int)
	ret := make([]int, 2)
	for k, v := range nums {
		addend := target - v
		if _, ok := vkMap[addend]; ok {
			ret[0] = vkMap[addend]
			ret[1] = k
		}
		vkMap[v] = k
	}
	fmt.Print(ret[0], ret[1])
}

func main() {
	var N int
	fmt.Scanf("%d", &N)
	var nums []int
	var temp int
	var target int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &temp)
		nums = append(nums, temp)
		nums[i] = temp
	}
	fmt.Scanf("%d", &target)
	twoSum(nums, target)
}